|
In computer programming, an indent style is a convention governing the indentation of blocks of code to convey the program's structure. This article largely addresses the free-form languages, such as C programming language and its descendants, but can be (and frequently is) applied to most other programming languages (especially those in the curly bracket family), where whitespace is otherwise insignificant. Indent style is just one aspect of programming style. Indentation is not a requirement of most programming languages, where it is used as secondary notation. Rather, programmers indent to better convey the structure of their programs to human readers. In particular, indentation is used to show the relationship between control flow constructs such as conditions or loops and code contained within and outside them. However, some programming languages (such as Python and occam) use the indentation to determine the structure instead of using braces or keywords; this is known as the off-side rule, and in these languages indentation is meaningful to the compiler, not just a matter of style. This article uses "brackets" to refer to what are known as "parentheses" in American English, and "braces" to refer to what are known as "curly brackets" in American English. == Placement of braces == The main difference between indent styles lies in the placement of the braces of the compound statement ( ) that often followsa control statement ( if , while ,for ...). The table below shows this placement for all thestyles discussed in this article. Note that, for consistency, the indent depth has been kept constant at 4 spaces, irrespective of the preferred indent depth of each style. | Allman |- | style="padding: 0 4px" | | GNU |- | style="padding: 0 4px" | | Whitesmiths |- | style="padding: 0 4px" | | Horstmann |- | style="padding: 0 4px" | | Pico |- | style="padding: 0 4px" | | Ratliff |- | style="padding: 0 4px" | | Lisp |} 抄文引用元・出典: フリー百科事典『 ウィキペディア(Wikipedia)』 ■ウィキペディアで「Indent style」の詳細全文を読む スポンサード リンク
|